<template>
  <div class="exhibits-box">
    <div class="textMax-box" ref="exhibits1Box">
      <titles :title="props.info.text" />
      <div class="subTitle" v-if="props.info.subTitle">——{{ props.info.subTitle }}</div>
      <div
        class="content-text-heard-item"
        :class="{
          'content-text-heard-item0': store.styleInfo.themeColor == '#CFBDA8',
          'content-text-heard-item1': store.styleInfo.themeColor == '#8F9EBF',
          'content-text-heard-item2': store.styleInfo.themeColor == '#B9463F',
          'content-text-heard-item3': store.styleInfo.themeColor == '#343029',
          'content-text-heard-item4': store.styleInfo.themeColor == '#171719',
        }"
      >
        <!-- <textMax :data="props.info.remarks" :maxLen="121" :tip="''" /> -->
        <van-text-ellipsis
          :content="getTrimText(props.info.remarks)"
          :rows="3"
          expand-text="展开"
          collapse-text="收起"
        />
      </div>
    </div>
    <div class="exhibits-img">
      <exhibitCom2Vue v-if="props.tabDatas.length === 2" :info="props.info" :tabDatas="tabDatas"></exhibitCom2Vue>
      <exhibitCom3Vue v-if="props.tabDatas.length === 3" :info="props.info" :tabDatas="tabDatas"></exhibitCom3Vue>
      <exhibitCom4Vue v-if="props.tabDatas.length === 4" :info="props.info" :tabDatas="tabDatas"></exhibitCom4Vue>
      <exhibitCom5Vue v-if="props.tabDatas.length === 5" :info="props.info" :tabDatas="tabDatas"></exhibitCom5Vue>
      <exhibitCom6Vue v-if="props.tabDatas.length === 6" :info="props.info" :tabDatas="tabDatas"></exhibitCom6Vue>
    </div>

    <div
      style="cursor: pointer"
      @click="pathChild"
      :style="{
        fontFamily: 'SourceHanSerifCN-Bold',
        color: '#fff',
      }"
      class="left-btn flex-c-c-c"
    >
      <div class="btn-img">
        <buttonIcon />
      </div>
      <span>查看全部</span>
    </div>
  </div>
</template>
<script setup lang="ts">
import { pathList, pathListLoop } from '../route';
import { urls } from '@/utils/request/upload';
import titles from '@/wap/wapPage/wapComponents/title/title.vue';
import buttonIcon from '@/wap/wapPage/wapComponents/title/buttonIcon.vue';
import { handlemouse, getTrimText } from '@/utils/minxin';
import { onMounted, ref } from 'vue';
import { useProjectStore } from '@/store';
import { useRouter, useRoute } from 'vue-router';
import textMax from '@/components/textMax/textMax.vue';
import exhibitCom2Vue from './exhibits3/exhibits3Com2.vue';
import exhibitCom3Vue from './exhibits3/exhibits3Com3.vue';
import exhibitCom4Vue from './exhibits3/exhibits3Com4.vue';
import exhibitCom5Vue from './exhibits3/exhibits3Com5.vue';
import exhibitCom6Vue from './exhibits3/exhibits3Com6.vue';
const route = useRoute();
const router = useRouter();
const store = useProjectStore();
const exhibits1Box = ref(null);
const props = defineProps({
  info: {
    type: Object,
  },
  tabDatas: {
    type: Array,
  },
});
const pathChild = () => {
  store.setchildModel(props.info);
  store.setCurrent(0);
  router.push({
    name: route.meta.loopType ? pathListLoop[8] : pathList[8],
    query: { childId: props.info.id },
  });
};
onMounted(() => {
  animation();
});
const animation = () => {
  let canTrigger = true; // 标记是否可以触发

  const observer = new IntersectionObserver((entries) => {
    entries.forEach((entry) => {
      if (entry.isIntersecting && canTrigger) {
        // 当元素进入视窗口时触发的代码s
        // console.log('c', exhibitsBox.value);
        exhibits1Box.value.classList.add('animation-box');

        // 设置一个延迟时间，防止频繁触发
        canTrigger = false;
        setTimeout(() => {
          canTrigger = true;
        }, 500); // 设置延迟时间为 500 毫秒
      } else {
        // if (exhibits1Box.value) {
        //   exhibits1Box.value.classList.remove('animation-box');
        // }
      }
    });
  });
  observer.observe(exhibits1Box.value);
};
</script>
<style scoped lang="less">
@import './index.less';
.exhibits-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0px;
}
.textMax-box {
  width: 100%;
  min-height: 112px;
  :deep(.tj) {
    line-height: 32px;
  }
}
.animation-box {
  animation: slideIn 1s forwards;
}
@keyframes slideIn {
  0% {
    // padding-right: 980px;
    transform: translateX(-100%); /* 元素初始位置 */
    opacity: 0;
  }
  100% {
    padding-right: 0px;
    opacity: 1;
    transform: translateX(0); /* 元素最终位置 */
  }
}

.content-text-heard-item0 {
  :deep(.van-text-ellipsis__action) {
    color: #d2ad77;
  }
}
.content-text-heard-item1 {
  :deep(.van-text-ellipsis__action) {
    color: #133889;
  }
}
.content-text-heard-item2 {
  :deep(.van-text-ellipsis__action) {
    color: #ab1d22;
  }
}
.content-text-heard-item3 {
  :deep(.van-text-ellipsis__action) {
    color: #3f4d4f;
  }
}
.content-text-heard-item4 {
  :deep(.van-text-ellipsis__action) {
    color: #949494;
  }
}
.content-text-heard-item {
  margin-top: 10px;
  padding: 0 16px;
}
.left-btn {
  margin-top: 10px;
}
.item-btm-shadow {
  width: 100%;
  height: 90px;
  position: absolute;
  bottom: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 100%);
}

.exhibits-img {
  padding: 0 16px;
}
.subTitle {
  padding: 0 16px;
  padding-top: 6px;
}
</style>
